package com.navidove.appspotlight.model.bo;

import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;

@Entity
@Table(name = "app_ad_item")
public class AppAdItem implements java.io.Serializable {

	private static final long serialVersionUID = 1L;
	
	public static final String AD_TYPE_AD = "AD";
	public static final String AD_TYPE_HOT = "HOT";

	private Long id;
	private SysImage sysImage;
	private AppItem appItem;
	private String slogn;
	private String adDesc;
	private Integer adSeq;
	private String adType;
	private String adUrl;
	private Boolean enable = true;
	private Date crtAt;
	private Date updAt;

	@Id
	@SequenceGenerator(name = "generator", sequenceName = "app_ad_item_id_seq", allocationSize = 1)
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "generator")
	public Long getId() {
		return this.id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "image_id", nullable = false)
	public SysImage getSysImage() {
		return this.sysImage;
	}

	public void setSysImage(SysImage sysImage) {
		this.sysImage = sysImage;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "app_item_id", nullable = true)
	public AppItem getAppItem() {
		return this.appItem;
	}

	public void setAppItem(AppItem appItem) {
		this.appItem = appItem;
	}
	
	@Column(name = "slogn", nullable = false, length = 100)
	public String getSlogn() {
		return this.slogn;
	}

	public void setSlogn(String slogn) {
		this.slogn = slogn;
	}

	@Column(name = "ad_desc", nullable = false)
	public String getAdDesc() {
		return this.adDesc;
	}

	public void setAdDesc(String adDesc) {
		this.adDesc = adDesc;
	}
	
	@Column(name = "ad_seq", nullable = false)
	public Integer getAdSeq() {
		return adSeq;
	}

	public void setAdSeq(Integer adSeq) {
		this.adSeq = adSeq;
	}
		
	@Column(name = "ad_type", nullable = false, length = 25)
	public String getAdType() {
		return adType;
	}

	public void setAdType(String adType) {
		this.adType = adType;
	}

	@Column(name = "ad_url", nullable = true)
	public String getAdUrl() {
		return adUrl;
	}

	public void setAdUrl(String adUrl) {
		this.adUrl = adUrl;
	}

	@Column(name = "enable")
	public Boolean getEnable() {
		return this.enable;
	}

	public void setEnable(Boolean enable) {
		this.enable = enable;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "crt_at", length = 29)
	public Date getCrtAt() {
		return this.crtAt;
	}

	public void setCrtAt(Date crtAt) {
		this.crtAt = crtAt;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "upd_at", length = 29)
	public Date getUpdAt() {
		return this.updAt;
	}

	public void setUpdAt(Date updAt) {
		this.updAt = updAt;
	}

	/**
	 * @see java.lang.Object#toString
	 * @return String
	 */
	public String toString() {
		return new ToStringBuilder(this).append("id", getId()).toString();

	}

	/**
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}
		if (obj == this) {
			return true;
		}
		if (obj.getClass() != getClass()) {
			return false;
		}
		AppAdItem rhs = (AppAdItem) obj;

		return new EqualsBuilder().append(getId(), rhs.getId()).isEquals();
	}

	/**
	 * @see java.lang.Object#hashCode()
	 */
	public int hashCode() {
		return new HashCodeBuilder(17, 37).append(getId()).toHashCode();
	}

}
